/**
 * 防抖函数
 * @param {function} callback 
 * @param {number} delay 
 * @param {boolean} firstFlag 
 */
export const useDebounce = (callback,
    delay = 500,
    firstFlag = true
) => {
    let timeout = null;
    return (...rest) => {
        if (!firstFlag){
            clearTimeout(timeout); 
            timeout = setTimeout(() =>callback(...rest),delay)
        }
        firstFlag = false
    }
}